﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;

namespace FridayPractice
{
    class DBHelper
    {
        public string sql;

        public static string conStr = "server=./;database=Users;Integrated Security=true";

        //验证
        public static SqlDataReader Select(string sql)
        {
            SqlConnection conn = new SqlConnection(conStr);
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);

            return cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
            //return cmd.ExecuteReader(System.Data. CommandBehavior.CloseConnection);
        }
        //添加
        public static bool Register(string sql)
        {
            bool result = false;

            SqlConnection conn = new SqlConnection(conStr);


            SqlCommand cmd = new SqlCommand(sql, conn);
            conn.Open();
            int number = cmd.ExecuteNonQuery();
            /*if (number>0)
            {
                result= true;
            }*/
            conn.Close();
            return number > 0;
        }
    }
}
